﻿@{
    ViewBag.Title = "工资册";
}
@section header{

}
<partial name="_page_list" />
@section scripts{
    <script>
        var baseUrl = "/reward/SalaryColumn/";
        $(function () {
            initControl();
        });
        function initControl() {
            $("#gridList").dataGrid({
                url: baseUrl + "GzlGridJson",
                datatype: "json",
                height: $(window).height() - 128,
                mtype: "POST",
                colModel: [
                    { label: "主键", name: "ID", hidden: true, key: true },
                    { label: '名称', name: 'Name', align: 'left' },
                    {
                        label: '添加时间', name: 'AddTime', width: 90, align: 'left',
                        formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' }
                    }
                ],
                rowNum: 20,
                rowList: [20, 50, 100],
                pager: '#gridPager',
                sortname: 'OrderBy',
                sortorder: "asc",
                viewrecords: true,
                autowidth: true,
                multiselect: true,
                loadComplete: function () {
                    $('.ui-jqgrid-bdiv').scrollTop(0);
                    setTimeout(function () { btn_tc(); });
                }
            });
            $("#btn_search").click(function () {
                $gridList.jqGrid('setGridParam', {
                    postData: { keyword: $("#txt_keyword").val() },
                }).trigger('reloadGrid');
            });
        }
        function btn_add() {
            $.modalOpen({
                id: "Form",
                title: "添加工资册",
                url: baseUrl + "Form?IfType=1",
                width: "700px",
                height: "440px",
                callBack: function (iframeId) {
                    top.frames[iframeId].submitForm();
                }
            });
        }
        function btn_edit() {
            var s = $("#gridList").jqGrid('getGridParam', 'selarrrow');
            if (s.length > 0) {
                var keyValue = s[0];
                $.modalOpen({
                    id: "Form",
                    title: "修改工资册",
                    url: baseUrl + "Form?IfType=1&keyValue=" + keyValue,
                    width: "700px",
                    height: "440px",
                    callBack: function (iframeId) {
                        top.frames[iframeId].submitForm();
                    }
                });
            } else {
                $.modalMsg("请选择一条数据", "error");
            }
        }
        function btn_delete() {
            var s = $("#gridList").jqGrid('getGridParam', 'selarrrow');
            if (s.length > 0) {
                console.log(s.toString())
                $.deleteForm({
                    url: baseUrl + "DeleteForm",
                    param: { keyValue: s.toString() },
                    success: function () {
                        $.currentWindow().$("#gridList").resetSelection();
                        $.currentWindow().$("#gridList").trigger("reloadGrid");
                    }
                })
            } else {
                $.modalMsg("请选择一条数据", "error");
            }
        }
    </script>
}